/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.isfd.util;

import cn.hutool.json.JSONObject;
import cn.hutool.json.serialize.JSONObjectSerializer;
import org.bson.types.ObjectId;

/**
 * @author THINK
 * @version v1.0
 * @className ObjectIdSerizlizer
 * @description _id的序列化转换器
 * @date 2024/6/12 14:11
 **/
public class ObjectIdSerizlizer implements JSONObjectSerializer<ObjectId>{
    private final Class<? extends ObjectId> ObjectIdClass;

    public ObjectIdSerizlizer(Class<? extends ObjectId> ObjectIdClass) {
        this.ObjectIdClass = ObjectIdClass;
    }
    @Override
    public void serialize(JSONObject entries, ObjectId objectId) {
        if (objectId != null) {
            entries.putOnce("_id", objectId.toString());
        }
    }

}
